package main

import (
	"crypto/md5"
	"encoding/json"
	"fmt"
	"git.inke.cn/chat11/server/user/user.feed.buz/model"
	"git.inke.cn/chat11/server/user/user.profile.buz/tools"
	"math"
	"strconv"
	"strings"
	"sync"
	"time"
)

func main() {
	re := md5.Sum([]byte("123456"))
	fmt.Printf("%x\n", re) // e10adc3949ba59abbe56e057f20f883e

}

func test12() {
	m := map[string]interface{}{
		"a":1,
	}
	r, _ := json.Marshal(m)
	fmt.Println(string(r))
}

func test13() {
	atomMap := make(map[string]interface{})
	err := json.Unmarshal([]byte(""), &atomMap)
	fmt.Println(err)
}

func CountExpectNumber(x int) int {
	y := 0
	if x > 0 && x <= 60 {
		y = int(1100/(1+math.Exp(-0.04*(float64(x)-60))) - 92)
	} else if x > 60 {
		y = int(290000/(1+math.Pow(1.6, -0.0004*(float64(x)-7050))) - 60650)
	}

	if y < 0 {
		y = 0
	}


	return y
}


func GetTomorrowUnix() int64 {
	currentTimeData := time.Date(time.Now().Year(), time.Now().Month(), time.Now().AddDate(0, 0, 1).Day(), 0, 0, 0, 0, time.Local)
	return currentTimeData.Unix()
}

func sliceTest() {
	a := make([]int, 0)
	wg := sync.WaitGroup{}
	var mu sync.Mutex
	for i := 0; i < 10; i++ {
		j := i
		wg.Add(1)
		go func() {
			defer wg.Done()
			mu.Lock()
			a = append(a, j)
			mu.Unlock()
		}()
	}
	wg.Wait()
	fmt.Println(a)
}

func test9() {
	fmt.Println(tools.GetShareCode(11416637))
}

func test8() {
	r := fmt.Sprintf("%.2f", float64(60)/100) //
	fmt.Println(r)
}
func test7() {
	keys := strings.Split("164231566929473:1644572686", ":")
	fmt.Println(keys)
}
func test6() {
	mp := map[string]int{"a": 1}
	if mp["b"] == 1 {
		fmt.Println(1111)
	} else {
		fmt.Println(fmt.Sprintf("%v", mp["b"]))
	}
}

func test5() {
	mp := map[string]bool{"a": true}
	if mp["b"] {
		fmt.Println(1111)
	} else {
		fmt.Println(fmt.Sprintf("%v", mp["b"]))
	}
}

func test4() {
	contentType := 0
	contentType |= model.UserFeedContentTypeImage //此处会变成
	fmt.Println(contentType)
	contentType |= model.UserFeedContentTypeVideo //此处会变成
	fmt.Println(contentType)
}

func test3() {
	res := make([]int, 0)
	res = []int{1, 2, 3, 4}
	fmt.Println(res[1:3])
}

type FeedTopicModel struct {
	Id    int    `json:"id"`   //下标
	Name  string `json:"name"` //话题名称
	Img   string `json:"img"`  //展示图
	Desc  string `json:"desc"` //话题描述
	Count int    `json:"count"`
}

func test2() {
	topics := map[int]FeedTopicModel{
		1: {
			Id:   1,
			Name: "今日份自拍",
			Img:  "",
			Desc: "还不知道什么时候告别单身生活？展示最真实的自己，吸引有缘人快快来相见！",
		},
		2: {
			Id:   2,
			Name: "新人报道",
			Img:  "",
			Desc: "新手玩家爆照区，快来和大家打个招呼吧~还会随机掉落撩对象小技巧带飞哦~",
		},
		3: {
			Id:   3,
			Name: "日常生活分享",
			Img:  "",
			Desc: "人生那么短，啤酒要喝完。生活是自己的，请尽情潇洒，尽情可爱~",
		},
		4: {
			Id:   4,
			Name: "我要找对象",
			Img:  "",
			Desc: "这里是单身男女的相亲角、脱单的许愿池，大胆表达自己，说出你的择偶标准，拼图的最后一块就在这里，参与话题，找到最适合你的人吧~",
		},
	}
	a := topics[8]

	maps := map[int]string{
		1: "2222",
	}
	b := maps[444]
	fmt.Println(a, b)
}

func test1() {
	a, _ := strconv.ParseBool("true")
	b, _ := strconv.ParseFloat("3.1415", 64)
	c, _ := strconv.ParseInt("-2", 10, 64)
	d, _ := strconv.ParseUint("-2", 10, 64)

	fmt.Printf("a:%v,b:%v,c:%v,d:%v", a, b, c, d)

	s1 := strconv.FormatBool(true)
	s2 := strconv.FormatFloat(3.1415, 'E', -1, 64)
	s3 := strconv.FormatInt(-2, 16)
	s4 := strconv.FormatUint(2, 16)

	fmt.Printf("----------------a:%v,b:%v,c:%v,d:%v", s1, s2, s3, s4)
}
